home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 19 / madtrb14.zip / BBS2.INC < prev    next >
Text File  |  1985-10-05  |  11KB  |  459 lines

  1. procedure sysoponly;
  2.  
  3.   var temp: char;
  4.  
  5.   procedure readcomments;
  6.  
  7.     var
  8.      comment: line;
  9.      comfile: file of line;
  10.  
  11.     begin
  12.       if cts then begin
  13.         clearsc;
  14.         assign(comfile, 'COMMENTS.BBS');
  15.         {$I-} reset(comfile) {$I+};
  16.         if IOresult <> 0 then rewrite(comfile);
  17.         while cts and (not cancelled) and not eof(comfile) do begin
  18.           read(comfile,comment);
  19.           lineout(comment);
  20.         end;
  21.         if getcap('Kill (Y/N)? ') = 'Y' then rewrite(comfile);
  22.         close(comfile);
  23.         unload;
  24.       end;
  25.     end;
  26.  
  27.   procedure changelevel;
  28.  
  29.     var
  30.      inch, number: integer;
  31.      temp: name;
  32.  
  33.     begin
  34.       repeat
  35.         number := getid('User name? ');
  36.         if number > 0 then begin
  37.           str(idrec.acc:2, temp);
  38.           lineout('Access:' + temp);
  39.           inch := getint(5, 0, 'New level? ');
  40.           idrec.acc := inch;
  41.           reset(idfile);
  42.           seek(idfile, number - 1);
  43.           write(idfile, idrec);
  44.           unload;
  45.         end;
  46.       until number = 0;
  47.     end;
  48.  
  49.   begin
  50.     repeat
  51.       temp := getcap('? ');
  52.       case temp of
  53.         'C': readcomments;
  54.         'L': changelevel;
  55.         '!': printon := not printon;
  56.       end;
  57.     until not ((temp in ['C','L','!']) and cts);
  58.   end;
  59.  
  60. procedure definecs;
  61.  
  62.   var
  63.     ch: char;
  64.     prompt: line;
  65.  
  66.   begin
  67.     ch := null;
  68.     while cts and not (ch in ['Q','Y']) do begin
  69.       lineout('The following input is NOT echoed until CR (RETURN) is pressed!');
  70.       prompt := 'Enter character(s) that will clear your screen (end with CR): ';
  71.       controls := true;
  72.       cs := getinput(prompt, 11, noecho);
  73.       controls := false;
  74.       clearsc;
  75.       ch := getcap(cr + lf + 'Did that do it (Y/N/Quit)? ');
  76.     end;
  77.     if ch = 'Q' then cs := lnfd;
  78.   end;
  79.  
  80. procedure definebs;
  81.  
  82.   begin
  83.     repeat
  84.       flush;
  85.       controls := true;
  86.       stringout('Type your backspace key: ');
  87.       bs := charin(echo);
  88.       controls := false;
  89.       lineout(space);
  90.     until not ((bs in [cr, tab, space, '0'..'9', 'A'..'Z', 'a'..'z']) and cts);
  91.   end;
  92.  
  93. procedure setwidth;
  94.  
  95.   var temp: integer;
  96.  
  97.   begin
  98.     repeat
  99.       temp := getint(132, 0, 'Enter your terminal width (chars/line): ');
  100.     until (temp in [0, 20..132]) or not cts;
  101.     if temp <> 0 then width := temp;
  102.   end;
  103.  
  104. procedure setvideo;
  105.  
  106.   var loop: byte;
  107.       inch: integer;
  108.       temp: name;
  109.  
  110.   function ctlchar(ch: char): name;
  111.  
  112.     begin
  113.       if ch > #127 then ch := chr(ord(ch) and 127);
  114.       case ch of
  115.         null..#31   : ctlchar := '^' + chr(ord(ch) + 64);
  116.         space..#126 : ctlchar := ch;
  117.         #127        : ctlchar := '<DEL>';
  118.       end;
  119.     end;
  120.  
  121.   procedure dispcontrol(ch: char);
  122.  
  123.     begin
  124.       if ch < #128 then stringout(ctlchar(ch))
  125.         else stringout(ctlchar(ch) + '(with 8th bit set)');
  126.     end;
  127.  
  128.   begin
  129.     repeat
  130.       clearsc;
  131.       lineout('Terminal parameters:' + cr + lf);
  132.       lineout('1 - Upper case only: ' + yn[caps]);
  133.       lineout('2 - Line feeds sent: ' + yn[lf = lnfd]);
  134.       lineout('3 - Prompt bell ON : ' + yn[bl = bell]);
  135.       stringout('4 - Backspace char.: ');
  136.       dispcontrol(bs);
  137.       lineout(space);
  138.       stringout('5 - Clear Screen   : ');
  139.       for loop := 1 to length(cs) do dispcontrol(cs[loop]);
  140.       lineout(space);
  141.       str(width:3, temp);
  142.       lineout('6 - Terminal width : ' + temp);
  143.       lineout(space);
  144.       inch := getint(6, 0, 'Enter number of parameter to change (0 to quit): ');
  145.       case inch of
  146.         1: caps := not caps;
  147.         2: if lf = lnfd then lf := null else lf := lnfd;
  148.         3: if bl = bell then bl := null else bl := bell;
  149.         4: definebs;
  150.         5: definecs;
  151.         6: setwidth;
  152.       end;
  153.     until (inch = 0) or not cts;
  154.     if cts then lineout('New definitions are saved by [G]oodbye command.');
  155.   end;
  156.  
  157. procedure chat;
  158.  
  159.   var
  160.     count  : byte;
  161.     inch   : char;
  162.  
  163.   begin
  164.     inch := null;
  165.     clearsc;
  166.     lineout('Entering chat mode: CTL-C aborts at any time.');
  167.     lineout('Summoning Sysop...');
  168.     flush;
  169.     count := 1;
  170.     repeat
  171.       count := count + 1;
  172.       charout(bell);
  173.       delay(1000);
  174.       if inready then inch := charin(noecho);
  175.     until (count > 10) or (inch <> null);
  176.     while cts and (inch <> abort) do begin
  177.       inch := charin(echo);
  178.       if inch = cr then sendout(lf);
  179.     end;
  180.   end;
  181.  
  182. procedure newpass;
  183.  
  184.   var
  185.     temp   : name;
  186.     prompt : line;
  187.  
  188.   begin
  189.     repeat
  190.       prompt := 'Enter the password you want on this system: ';
  191.       password := allcaps(getinput(prompt, 14,noecho));
  192.       prompt := cr + lf + 'Enter it again, to be sure: ';
  193.       temp := allcaps(getinput(prompt, 14, noecho));
  194.       if temp <> password then lineout('Passwords did not match.');
  195.     until (temp = password) or not cts;
  196.     lineout('New password is saved when the [G]oodbye command is executed.');
  197.   end;
  198.  
  199. procedure listusers;
  200.  
  201.   var
  202.     tempid: sysid;
  203.     inch:   name;
  204.  
  205.   begin
  206.     if cts then begin
  207.       clearsc;
  208.       reset(idfile);
  209.       str(filesize(idfile):4, inch);
  210.       lineout(inch + ' users registered.');
  211.       while cts and not(eof(idfile) or cancelled) do begin
  212.         read(idfile,tempid);
  213.         if access = sysop then begin
  214.           str(tempid.acc:1, inch);
  215.           stringout(inch + '  ');
  216.         end;
  217.         lineout(tempid.user);
  218.       end;
  219.       unload;
  220.     end;
  221.   end;
  222.  
  223. procedure userlog;
  224.  
  225.   var
  226.     call:   person;
  227.     loop:   integer;
  228.  
  229.   begin
  230.     if cts then begin
  231.       clearsc;
  232.       {$I-} reset(logfile) {$I+};
  233.       if IOresult <> 0 then rewrite(logfile);
  234.       while cts and (not cancelled) and not eof(logfile) do begin
  235.         read(logfile,logrec);
  236.         if logrec.who < 1 then call := ('Not on userlist')
  237.           else call := getname(logrec.who);
  238.         if clockin then for loop := length(call)+1 to 25 do call := call+space;
  239.         stringout(call);
  240.         if clockin then stringout(logrec.when + ' to ' + logrec.done);
  241.         lineout(space);
  242.       end;
  243.       if access = sysop then begin
  244.         if getcap('Kill (Y/N)? ') = 'Y' then rewrite(logfile);
  245.       end;
  246.       close(logfile);
  247.       unload;
  248.     end;
  249.   end;
  250.  
  251. procedure enterpass;
  252.  
  253.   var
  254.     temp:  name;
  255.     tries: byte;
  256.  
  257.   begin
  258.     tries := 0;
  259.     lineout(space);
  260.     repeat
  261.       if tries > 0 then stringout('Incorrect - try again: ');
  262.       tries := tries + 1;
  263.       temp := allcaps(getinput('Enter your password: ', 14, noecho));
  264.     until (temp = idrec.pass) or (tries = 3) or not cts;
  265.     if (temp <> idrec.pass) then hangup;
  266.   end;
  267.  
  268. procedure getdefaults;
  269.  
  270.   begin
  271.     enterpass;
  272.     if cts then begin
  273.       with idrec do begin
  274.         password := pass;
  275.         expert := (exfl = 0);
  276.         access := acc;
  277.         cs := clr;
  278.         bs := bsp;
  279.         lf := lnf;
  280.         caps := upc;
  281.         width := wid;
  282.         lastmess := lstm;
  283.         if clockin then lineout('Last on: ' + lsto);
  284.       end;
  285.     end;
  286.   end;
  287.  
  288. procedure introduce;
  289.  
  290.   begin
  291.     lineout(cr + lf + 'Getting new user password & terminal info:');
  292.     if cts then begin
  293.       newpass;
  294.       setvideo;
  295.       if caller = 'SYSOP' then access := sysop else access := newuser;
  296.     end;
  297.   end;
  298.  
  299. procedure signon(var caller: person);
  300.  
  301.   var ch: char;
  302.       tries: byte;
  303.  
  304.   begin
  305.     ch := space;
  306.     tries := 0;
  307.     repeat
  308.       tries := tries + 1;
  309.       repeat
  310.         caller := allcaps(getinput('What is your full name? ', 28, echo));
  311.       until (length(caller) > 4) or not cts;
  312.       if cts then begin
  313.         usernum := findid(caller);
  314.         if (local or openBBS) and (usernum=0) then
  315.           ch:=getcap(caller + ': is this correct (Y/N)? ');
  316.       end;
  317.       if (tries >= 3) and (usernum=0) and not openBBS then hangup;
  318.     until (usernum > 0) or (ch = 'Y') or not cts;
  319.     if cts then begin
  320.       if usernum = 0 then introduce else getdefaults;
  321.       dispcaller;
  322.       if access = twit then begin
  323.         lineout('User ' + caller + ' has been denied system access.');
  324.         hangup;
  325.       end;
  326.     end;
  327.   end;
  328.  
  329. procedure logcall;
  330.  
  331.   begin
  332.     {$I-} reset(logfile) {$I+};
  333.     if IOresult <> 0 then rewrite(logfile);
  334.     seek(logfile, filesize(logfile));
  335.     with logrec do begin
  336.       who := usernum;
  337.       if clockin then begin
  338.         when := timeon;
  339.         done := timeoff;
  340.       end;
  341.     end;
  342.     write(logfile, logrec);
  343.     close(logfile);
  344.   end;
  345.  
  346. procedure endcall;
  347.  
  348.   begin
  349.     if clockin then begin
  350.       clock(offmonth, offdate, offhour, offmin, offsec);
  351.       timeoff := time(offmonth, offdate, offhour, offmin, offsec);
  352.     end;
  353.     logcall;
  354.   end;
  355.  
  356. procedure readmine;
  357.  
  358.   begin
  359.     if cts and (usernum > 0) then begin
  360.       lineout('Checking for your mail...');
  361.       messagesearch(1,0,usernum,0);
  362.     end;
  363.   end;
  364.  
  365. procedure relog;
  366.  
  367.   begin
  368.     endcall;
  369.     if clockin then begin
  370.       clock(onmonth, ondate, onhour, onmin, onsec);
  371.       timeon := time(onmonth, ondate, onhour, onmin, onsec);
  372.     end;
  373.     signon(caller);
  374.     status;
  375.     readmine;
  376.   end;
  377.  
  378. procedure apply;
  379.  
  380.   begin
  381.     outfile(applying);
  382.     getcomments(4);
  383.   end;
  384.  
  385. procedure command;
  386.  
  387.   var
  388.     prompt: line;
  389.     inch  : char;
  390.     first : boolean;
  391.  
  392.   begin
  393.     first := true;
  394.     while cts do begin
  395.       if first and not expert then outfile(mainmenu);
  396.       unload;
  397.       prompt := cr + lf + 'Command: ';
  398.       if not expert
  399.         then prompt := prompt + 'A,B,C,E,F,G,H,I,K,L,M,N,O,P,R,S,U,W,X,Y,# ? '
  400.         else prompt := prompt + '(? for menu) ? ';
  401.       flush;
  402.       inch := getcap(prompt);
  403.       first := true;
  404.       case inch of
  405.         'A': apply;
  406.         'B': outfile(bulletin);
  407.         'C': chat;
  408.         'E': enter;
  409.         'F': filesys;
  410.         'G': disconnect;
  411.         'H': outfile(helpfile);
  412.         'I': setvideo;
  413.         'K': deletex;
  414.         'L': userlog;
  415.         'M': outfile(meetings);
  416.         'N': messagesearch(findfirst(lastmess + 1), 0, 0, 0);
  417.         'O': outfile(otherBBS);
  418.         'P': newpass;
  419.         'Q': relog;
  420.         'R': receive;
  421.         'S': quickscan;
  422.         'U': listusers;
  423.         'W': outfile(welcome);
  424.         'X': begin expert := not expert; first := false; end;
  425.         'Y': outfile(sysinfo);
  426.         '#': begin status; showtime; connecttime; first := false; end;
  427.         '?': if expert then outfile(mainmenu);
  428.         '@': if access=sysop then sysoponly else first := false;
  429.         '!': if access=sysop then printon := not printon else first := false;
  430.         else first := false;
  431.       end; {case}
  432.     end; {while cts}
  433.   end; {command}
  434.  
  435. procedure defaults;
  436.  
  437.   begin
  438.     lf := lnfd;
  439.     bl := null;
  440.     cs := lnfd;
  441.     bs := bksp;
  442.     expert := false;
  443.     caps := false;
  444.     width := 80;
  445.     access := newuser;
  446.     assign(idfile, 'IDS.BBS');
  447.     assign(logfile, 'LOG.BBS');
  448.     lastmess := 0;
  449.     caller := space;
  450.     usernum := 0;
  451.     messopen := false;
  452.     filesopen := false;
  453.     printon := false;
  454.     inbuffer := '';
  455.     cancelled := false;
  456.     controls := false;
  457.   end;
  458.  
  459.